package domain;

import java.util.Collection;
import java.util.HashSet;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@Entity
@Access(AccessType.PROPERTY)
@Table(uniqueConstraints = { @UniqueConstraint(columnNames = { "userAccount_id" }),
							 @UniqueConstraint(columnNames = { "number" })  })

public class Customer extends Actor {
	
	// Constructors//
	public Customer(){
		super();
		comments = new HashSet<Comment>();
		bids = new HashSet<Bid>();
		paintings = new HashSet<Painting>();
		ownershipHistories = new HashSet<OwnershipHistory>();
		galleries = new HashSet<Gallery>();
		auctions = new HashSet<Auction>();
		
	}
	//Attributes//
		private CreditCard creditCard;
		
	@NotNull
	@Valid
	public CreditCard getCreditCard() {
		return creditCard;
	}
	
	public void setCreditCard(CreditCard creditCard) {
		this.creditCard = creditCard;
	}
	
	// Relationships//
	
	private Collection<Comment> comments;
	private Collection<Bid> bids;
	private Collection<Painting> paintings;
	private Collection<OwnershipHistory> ownershipHistories;
	private Collection<Gallery> galleries;
	private Collection<Auction> auctions;
	
	@OneToMany(mappedBy = "customer")
	public Collection<Comment> getComments() {
		return comments;
	}

	public void setComments(Collection<Comment> comments) {
		this.comments = comments;
	}
	@OneToMany(mappedBy = "customer")
	public Collection<Bid> getBids() {
		return bids;
	}

	public void setBids(Collection<Bid> bids) {
		this.bids = bids;
	}
	@OneToMany(mappedBy = "customer")
	public Collection<Painting> getPaintings() {
		return paintings;
	}

	public void setPaintings(Collection<Painting> paintings) {
		this.paintings = paintings;
	}
	@OneToMany(mappedBy = "customer")
	public Collection<OwnershipHistory> getOwnershipHistories() {
		return ownershipHistories;
	}

	public void setOwnershipHistories(Collection<OwnershipHistory> ownershipHistories) {
		this.ownershipHistories = ownershipHistories;
	}
	@OneToMany(mappedBy = "customer")
	public Collection<Gallery> getGalleries() {
		return galleries;
	}

	public void setGalleries(Collection<Gallery> galleries) {
		this.galleries = galleries;
	}
	@OneToMany(mappedBy = "customer")
	public Collection<Auction> getAuctions() {
		return auctions;
	}

	public void setAuctions(Collection<Auction> auctions) {
		this.auctions = auctions;
	}
	
}
